﻿public class ModuleStateService
{
    public bool IsStopped { get; set; } = false;
    private Dictionary<string, bool> _moduleExecutionStatus = new Dictionary<string, bool>();

    public void StopAllModules()
    {
        IsStopped = true;
    }

    public void Reset()
    {
        IsStopped = false;
    } 

    public bool GetModuleExecutionStatus(string moduleId)
    {
        if (_moduleExecutionStatus.ContainsKey(moduleId))
        {
            return _moduleExecutionStatus[moduleId];
        }
        return false;
    }

    public void SetModuleExecutionStatus(string moduleId, bool status)
    {
        _moduleExecutionStatus[moduleId] = status;
    }

    // 注册模块的 Id
    public void RegisterModule(string moduleId)
    {
        if (!_moduleExecutionStatus.ContainsKey(moduleId))
        {
            _moduleExecutionStatus[moduleId] = false; // 初始状态为未执行
        }
    }
}